package com.xiyue.lenovo.startactivity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class secondActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        //获取应用程序中的previous
        Button previous = (Button) findViewById(R.id.previous);
        //获取应用程序中的close按钮
        Button close = (Button) findViewById(R.id.close);
        //为previous按钮绑定事件监听器
        previous.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取启动当前Activity的上一个Intent
                Intent intent = new Intent(secondActivity.this,MainActivity.class);
                //启动intent对应的Activity
                startActivity(intent);
            }
        });
        //为close按钮绑定事件监听器
        close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取启动当前Activity的上一个Intent
                Intent intent = new Intent(secondActivity.this,MainActivity.class);
                //启动intent对应的Activity
                startActivity(intent);
                //结束当前的Activity
                finish();
            }
        });
    }
}
